<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Promise模块化发送Ajax请求</title>
  <script src="script/jquery-3.7.1.min.js"></script>
  <script type="text/javascript">
    get = (url, data) => {
      return new Promise((resolve, reject) => {
        $.ajax({
          url: url,
          data: data,
          success(data) {
            console.log("请求的数据:", data);
            resolve(data);
          },
          error(data) {
            reject(data);
          }
        })
      })
    }
    let p = get(`data/cat.json`);
    p.then(data => {
      return get(`data/cat${data.id}_detail.json`);
    }).then(data => {
      return get(`data/cat${data.gf_id}_detail.json`);
    }).catch(data => {
      console.log("error:", data);
    })
  </script>
</head>
<body>
</body>
</html>
